/*
 * Copyright(C) 2012 Luvina Software Company
 *
 * MstGroupLogicImpl.java, May 29, 2012 HaiPD
 */
package net.luvina.manageuser.logic.impl;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import net.luvina.manageuser.dao.MstGroupDao;
import net.luvina.manageuser.hibernate.MstGroup;
import net.luvina.manageuser.logic.MstGroupLogic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * MstGroupLogicImpl implements MstGroupLogic
 *
 * @author HaiPD
 *
 */
@Service("groupLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class MstGroupLogicImpl implements MstGroupLogic {

	@Autowired
	private MstGroupDao groupDao;

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.MstGroupLogic#getGroupList()
	 */
	@Override
	public List<SelectItem> getListItemGroup(String defaultValue) {
		List<MstGroup> listGroup = this.groupDao.getListGroup();
		SelectItem selectItemGroup;
		List<SelectItem> itemGroups = new ArrayList<SelectItem>();
		itemGroups.add(new SelectItem("", defaultValue));
		for (MstGroup group : listGroup) {
			selectItemGroup = new SelectItem(group.getGroupId(), group
					.getGroupName());
			itemGroups.add(selectItemGroup);
		}
		return itemGroups;
	}

}
